import { _decorator, Component, Node, Label, director, color, Color, Camera } from 'cc';
import { UICtrl, UIMgr } from '../../Managers/UIMgr';
const { ccclass, property } = _decorator;

@ccclass('UIGame_Ctrl')
export class UIGame_Ctrl extends UICtrl {

    private verLabel: Label = null

    private colors: Array<any> = [
        Color.WHITE,
        Color.BLUE
    ]

    onLoad() {
        super.onLoad()

        // 更新版本号
        this.verLabel = this.view['Version'].getComponent(Label)

        this.verLabel.string = '版本 2.0'
        this.updateVerColor()

        // 监听click
        this.addButtonListen('BtnStart', this, this.onStartClick)
        this.addButtonListen('BtnTest', this, this.onTestClick)
    }

    private onStartClick() {
        UIMgr.Instance.removeUI('UIGame')
        UIMgr.Instance.hideUI('Loading')
        UIMgr.Instance.showUI('ShowRoom')
    }

    private onTestClick() {
        // 跳转场景二
        director.loadScene('World1')
    }

    start() {

    }

    update(deltaTime: number) {
        
    }

    private updateVerColor() {
        if (!this.verLabel) return
        this.verLabel.color = this.colors[0]
    }
}

